package liumengbaio.lolzhangyoubao.Activity.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.squareup.picasso.Picasso;

import java.util.List;

import liumengbaio.lolzhangyoubao.Activity.InFo.SummonerSkillsInfo;
import liumengbaio.lolzhangyoubao.R;

/**
 * Created by lanouhn on 16/9/1.
 */
public class MoreSummonerAdapter extends BaseAdapter {

    private List<SummonerSkillsInfo> mSummonerSkillsInfos;
    private Context mContext;


    public MoreSummonerAdapter(List<SummonerSkillsInfo> mSummonerSkillsInfos, Context mContext) {
        this.mSummonerSkillsInfos = mSummonerSkillsInfos;
        this.mContext = mContext;
    }

    @Override
    public int getCount() {
        return mSummonerSkillsInfos.size();
    }

    @Override
    public Object getItem(int position) {
        return mSummonerSkillsInfos.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder holder = null;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = LayoutInflater.from(mContext).inflate(R.layout.item_more_summonerskills, null);
            holder.iv = (ImageView) convertView.findViewById(R.id.more_summoner_iv);
            holder.tv = (TextView) convertView.findViewById(R.id.more_summoner_tv);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        SummonerSkillsInfo ssi=mSummonerSkillsInfos.get(position);
        holder.tv.setText(ssi.getName());
        Picasso.with(mContext).load(ssi.getPic_url()).into(holder.iv);
        return convertView;
    }

    private class ViewHolder {
        private ImageView iv;
        private TextView tv;
    }
}
